import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:grocery_app_demo/pages/drawer/controller.dart';
import 'package:grocery_app_demo/routes/app_routes.dart';
import 'package:grocery_app_demo/widgets/gap.dart';

class CommonDrawer extends GetView<MyDrawerController> {
  const CommonDrawer({super.key});

  @override
  Widget build(BuildContext context) {
    Get.put(MyDrawerController());

    return Drawer(
      child: ListView(
        padding: EdgeInsets.zero,
        children: [
          Obx(
            () => DrawerHeader(
                child: Row(
                  children: [
                    ClipOval(
                      child: Container(
                        width: 100.w,
                        height: 100.w,
                        alignment: Alignment.center,
                        color: Colors.deepPurpleAccent,
                        child: const Text(
                          'K',
                          style: TextStyle(color: Colors.white, fontSize: 46),
                        ),
                      ),
                    ),
                    gapW16,
                    Text(
                      controller.username.value,
                      style: const TextStyle(color: Colors.white),
                    ),
                  ],
                )),
          ),
          InkWell(
            onTap: () => Get.offAllNamed(AppRoutes.purchase),
            child: ListTile(
              leading: const Icon(Icons.message),
              title: Text('采购管理'.tr),
            ),
          ),
          InkWell(
            onTap: () => Get.offAllNamed(AppRoutes.aboutPage),
            child: ListTile(
              leading: const Icon(Icons.account_circle),
              title: Text('出入库'.tr),
            ),
          ),
          InkWell(
            onTap: () => Get.offAllNamed(AppRoutes.settingPage),
            child: ListTile(
              leading: const Icon(Icons.settings),
              title: Text('设置'.tr),
            ),
          ),
        ],
      ),
    );
  }
}
